function a() {
    layui.use('layer', function () {
        var layer = layui.layer;
        layer.open({
            type: 2,
            area: ['600px', '400px'],
            content: 'orderDetail.html'
        })
    })
}
layui.use('table', function () {
    var table = layui.table;

    table.render({
        elem: '#test'
        , url: 'jay/Order/getCheckOrders'
        , defaultToolbar: ['filter', 'exports', 'print', {
            title: '提示'
            , layEvent: 'LAYTABLE_TIPS'
            , icon: 'layui-icon-tips'
        }]
        , title: '用户数据表'
        , even: true
        , id: 'testReload'
        , parseData: function (res) { //res 即为原始返回的数据
            return {
                "code": 0, //解析接口状态
                "msg": "", //解析提示文本
                "count": res.obj.total, //解析数据长度
                "data": res.obj.list //解析数据列表
            };
        }
        , cols: [[
            { field: 'id', title: 'ID', width: 80, align: 'center', fixed: 'left', unresize: true, sort: true }
            , { field: 'orderCode', title: '订单号', align: 'center', width: 120, unresize: true }
            , { field: 'cusName', title: '客户名称', align: 'center', width: 80, unresize: true }
            , { field: 'createDate', title: '创建时间', align: 'center', width: 120, unresize: true, sort: true }
            , {
                field: 'orderStatus', title: '订单状态', align: 'center', width: 120, unresize: true, sort: true, templet: function (d) {
                    if (d.orderStatus == 3 || d.orderStatus == 4) {  // 自定义内容
                        return "已审核";
                    } else if (d.orderStatus == 1) {
                        return "未审核";
                    } else if (d.orderStatus == 2) {
                        return "审核未通过";
                    }
                }
            }
            , {
                field: 'paymentStatus', title: '支付状态', align: 'center', width: 120, unresize: true, sort: true, templet: function (d) {
                    if (d.paymentStatus == 3) {  // 自定义内容
                        return "已结算";
                    } else if (d.paymentStatus == 1) {
                        return "未付款";
                    } else {
                        return "部分付款";
                    }
                }
            }
            , { field: 'amountPaid', title: '已付金额', align: 'center', width: 120, unresize: true, sort: true }
            , { field: 'totalAmount', title: '总金额', align: 'center', width: 120, unresize: true, sort: true }
            , { field: 'orderExpirationTime', align: 'center', title: '过期时间', width: 120, unresize: true, sort: true }
            , { fixed: 'right', title: '操作', align: 'center', toolbar: '#barDemo' }
        ]]
        , page: true
        , even: true
    });
    var $ = layui.$, active = {
        reload: function () {
            table.reload('testReload', {
                page: {
                    curr: 1//默认从第一页开始加载
                },
                where: {
                    orderStatus: $('#orderStatus').val(),
                    createDate: $('#createDate').val(),
                }
            });
        }
    }
    $('#find').on('click', function () {
        var type = 'reload';
        active[type] ? active[type].call(this) : '';
    });
    //监听行工具事件
    table.on('tool(test)', function (obj) {
        var data = obj.data;
        if (obj.event === 'detail') {
            layer.open({
                type: 2,
                area: ['600px', '380px'],
                maxmin: true, //开启最大化最小化按钮
                content: "orderDetail2.html",
                success: function (layero, index) {
                    var iframe = window['layui-layer-iframe' + index];
                    iframe.relo(data.id);
                }
            });
        } else if (obj.event === "audit") {
            layer.confirm('<h3 style=\'text-align: center;color: green\'>是否审核</h3>', {
                btn: ['确认审核', '取消审核']
            }, function (index, layero) {
                $.post('jay/Order/checkSuccess', 'id=' + data.id, function (data) {
                    if (data.obj != 0 || data.obj != null) {
                        layer.msg("审核成功", { icon: 1 });
                        table.reload('testReload', {
                            page: {
                                curr: 1
                            }
                        });
                    } else {
                        layer.msg("审核失败，请稍后再试!", { icon: 2 });
                        table.reload('testReload', {
                            page: {
                                curr: 1
                            }
                        })
                    }
                }, 'JSON');
            }, function (index) {
                layer.msg("您取消了操作", { icon: 2 })
            })
        } else if (obj.event === 'unaudit') {
            layer.confirm('<h3 style=\'text-align: center;color: red\'>是否审核不通过</h3>', {
                btn: ['确认审核不通过', '取消审核不通过']
            }, function (index, layero) {
                $.post('jay/Order/checkFail', 'id=' + data.id, function (data) {
                    if (data.obj != 0 || data.obj != null) {
                        layer.msg("审核不通过成功", { icon: 1 });
                        table.reload('testReload', {
                            page: {
                                curr: 1
                            }
                        });
                    } else {
                        layer.msg("审核不通过失败，请稍后再试!", { icon: 2 });
                        table.reload('testReload', {
                            page: {
                                curr: 1
                            }
                        });
                    }
                }, 'JSON');
            }, function (index) {
                layer.msg("您取消了操作!", { icon: 2 })
            })
        }
    });
    $.ajax({
        url: 'jay/Order/getCheckStatus',
        type: 'post',
        dataType: 'JSON',
        success: function (data) {
            var data = data.obj;
            for (var i = 0; i < data.length; i++) {
                $("#orderStatus").append("<option value=\"" + data[i].id + "\">" + data[i].statusName + "</option>");
            }
            layui.form.render("select");
        }
    })
});